<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
		"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>robot ConfirmDialog A11Y Test</title>

<style>
	<style>
	@import "../../../util/doh/robot/robot.css";
</style>

<!-- required: dojo.js -->
<script type="text/javascript" src="../../../dojo/dojo.js"
		data-dojo-config="isDebug: true"></script>

<script type="text/javascript">
require([
	"doh/runner", "dojo/robotx",
	"dojo/dom", "dojo/keys",
	"dijit/tests/helpers", "dojo/domReady!"
], function(doh, robot, dom, keys, helpers){

	robot.initRobot('../test_ConfirmTooltipDialog.html');

	doh.register(function setup(){
		dfocus = robot.window.require("dijit/focus");
	});

	doh.register("ColorPicker", [
		{
			name: "OK",
			timeout: 10000,
			runTest: function(){
				var d = new doh.Deferred();

				// Open drop down
				dom.byId("colorButton").focus();
				robot.keyPress(keys.SPACE, 1000, {});

				// Select a color
				robot.keyPress(keys.RIGHT_ARROW, 500, {});
				robot.keyPress(keys.DOWN_ARROW, 500, {});
				robot.keyPress(keys.SPACE, 500, {});

				// Submit
				robot.keyPress(keys.TAB, 500, {});
				robot.keyPress(keys.SPACE, 500, {});

				robot.sequence(d.getTestCallback(function(){
					doh.t(helpers.isHidden("colorDlg"), "dialog hidden");
					doh.is("#ffc0cb", dom.byId("selectedColor").value, "selected color");
				}), 500);

				return d;
			}
		},

		{
			name: "Cancel",
			timeout: 10000,
			runTest: function(){
				var d = new doh.Deferred();

				// Open drop down
				dom.byId("colorButton").focus();
				robot.keyPress(keys.SPACE, 1000, {});

				// Cancel
				robot.keyPress(keys.TAB, 500, {});
				robot.keyPress(keys.TAB, 500, {});
				robot.keyPress(keys.SPACE, 500, {});

				robot.sequence(d.getTestCallback(function(){
					doh.t(helpers.isHidden("colorDlg"), "dialog hidden");
					doh.is("", dom.byId("selectedColor").value, "selected color");
				}), 500);

				return d;
			}
		}
	]);

	doh.register("Form", [
		{
			name: "OK",
			timeout: 10000,
			runTest: function(){
				var d = new doh.Deferred();

				// Open drop down
				dom.byId("loginButton").focus();
				robot.keyPress(keys.SPACE, 1000, {});

				// Enter some data
				robot.typeKeys("scott", 1000, 800);
				robot.keyPress(keys.TAB, 500, {});
				robot.typeKeys("tiger", 1000, 800);

				// Submit
				robot.keyPress(keys.TAB, 500, {});
				robot.keyPress(keys.SPACE, 500, {});

				robot.sequence(d.getTestCallback(function(){
					doh.t(helpers.isHidden("loginDlg"), "dialog hidden");
					doh.is("scott/tiger", dom.byId("formData").value, "form data");
				}), 500);

				return d;
			}
		},

		{
			name: "tabbing loops around",
			timeout: 10000,
			runTest: function(){
				var d = new doh.Deferred();

				// Open drop down
				dom.byId("loginButton").focus();
				robot.keyPress(keys.SPACE, 1000, {});	// focuses "name"

				robot.keyPress(keys.TAB, 500, {});	// to "password"
				robot.keyPress(keys.TAB, 500, {});	// to "OK"
				robot.keyPress(keys.TAB, 500, {});	// to "Cancel"
				robot.keyPress(keys.TAB, 500, {});	// to "name"

				robot.sequence(d.getTestCallback(function(){
					doh.is("user", dfocus.curNode.name, "focus looped back to name field");
				}), 500);

				return d;
			}
		}
	]);

	doh.run();
});
</script>
</head>
</html>
